package net.xiduth.game.player.content;

import java.util.HashMap;
import java.util.Map;

import net.xiduth.cache.loaders.ItemDefinitions;
import net.xiduth.game.Animation;
import net.xiduth.game.Graphics;
import net.xiduth.game.item.Item;
import net.xiduth.game.player.Player;
import net.xiduth.game.player.Skills;
import net.xiduth.game.tasks.WorldTask;
import net.xiduth.game.tasks.WorldTasksManager;
import net.xiduth.utils.Logger;

public class RCObelisks {
public static int COSMIC = 564;
public static int AIR = 556;
	public enum orbstoOffer {
		AIRORB(573, 75);
		private int id;
		private double experience;
		private static Map<Integer, orbstoOffer> airorbs = new HashMap<Integer, orbstoOffer>();

		static {
			for (orbstoOffer Orb : orbstoOffer.values()) {
				airorbs.put(Orb.getId(), Orb);
			}
		}

		public static orbstoOffer forId(int id) {
			return airorbs.get(id);
		}

		private orbstoOffer(int id, double experience) {
			this.id = id;
			this.experience = experience;
		}

		public int getId() {
			return id;
		}

		public double getExperience() {
			return experience;
		}

		public static boolean stopOffer = false;

		public static void RunObelisk(final Player player, Item item) {
			final int itemId = item.getId();
			new ItemDefinitions(item.getId());
			final orbstoOffer orbs = orbstoOffer.forId(item.getId());
			WorldTasksManager.schedule(new WorldTask() {
				public void run() {
					try {
						if (!player.getInventory().containsItem(itemId, 1)) {
							if (player.getInventory().containsItem(COSMIC, 5)) {
								if (player.getInventory().containsItem(AIR, 3)) {
							stop();
							return;
						}
							}
						}
						player.getPackets().sendGameMessage(
								"You bless the air orb, it becomes a staff.");
						player.setNextAnimation(new Animation(791));
						player.getInventory().addItem(1397, 1);
				        player.setNextGraphics(new Graphics(150));
						player.getInventory().deleteItem(new Item(itemId, 1));
						player.getInventory().deleteItem(new Item(AIR, 3));
						player.getInventory().deleteItem(new Item(COSMIC, 5));
						
						double xp = orbs.getExperience()
								* player.getAuraManager().getPrayerMultiplier();
						player.getSkills().addXp(Skills.RUNECRAFTING, xp);
						player.getInventory().refresh();
					
					}
					catch (Throwable e) {
						Logger.handle(e);
					}
	
				}
			}, 0, 3);
		}
		}
}